package com.yezi.lampcourt.ui.adapter;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yezi.lampcourt.R;
import com.yezi.lampcourt.entity.ModeBean;

import java.util.List;

/**
 * Created by HongMing Ye
 * on 2017/10/10 0010.
 */

public class ModeAdapter extends BaseQuickAdapter<ModeBean, BaseViewHolder> {
    public ModeAdapter(@LayoutRes int layoutResId, @Nullable List<ModeBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ModeBean item) {
        int modeImg = 0;
        switch (item.getModeId()) {
            case "1":
                modeImg = R.drawable.ic_match;
                break;
            case "2":
                modeImg = R.drawable.ic_practice;
                break;
            case "3":
                modeImg = R.drawable.ic_relax;
                break;
            case "4":
                modeImg = R.drawable.ic_clean;
                break;
        }
        ImageView ivMode = helper.getView(R.id.iv_mode);
        TextView tvMode = helper.getView(R.id.tv_mode);
        LinearLayout llModeBackground = helper.getView(R.id.ll_mode_background);

        ivMode.setImageResource(modeImg);
        tvMode.setText(item.getModeName());

        int textColor = item.isSelected() ? R.color.colorAccent : R.color.textColor333;
        int backgroundColor = item.isSelected() ? R.color.white : R.color.white_f3;
        ivMode.setSelected(item.isSelected());
        tvMode.setTextColor(mContext.getResources().getColor(textColor));
        llModeBackground.setBackgroundColor(mContext.getResources().getColor(backgroundColor));

    }
}
